--
-- @Author:      name
-- @DateTime:    2018-03-30 23:05:48
-- @Description: 用户表
local Entity = require "entitybase.Entity"

local tbname = 'usergame'
local TB = class(tbname, Entity)

function TB:ctor(operate)
	TB.super.ctor(self)
	self.tbname = tbname
	self.operate = operate
	self.msg = operate.msg
	--注册消息
	self:register()
end

function TB:register()
	self.msg:registerSelf('add_role',handler(self,self.add))
	self.msg:registerSelf('get_role',handler(self,self.get))	
	self.msg:registerSelf('delete_role',handler(self,self.delete))
	self.msg:registerSelf('update_role',handler(self,self.update))
	self.msg:registerSelf('reload_role',handler(self,self.reload))
	self.msg:registerSelf('unload_role',handler(self,self.unload))	
	self.msg:registerSelf('save_role',handler(self,self.saveRole))

end

function TB:saveRole(row)
	if not row.playerid and not row.uid then 
		return
	end
	if row.playerid then 
		row.uid = row.playerid
		row.playerid = nil
	end
	if self:get(row.uid) then 
		self:update(row)
	else
		self:add(row)
	end
end



return TB
